<template>
  <a-card :bordered="false" :loading="cardLoading">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="10">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="请选择时间">
              <a-date-picker
                placeholder="请选择时间"
                mode="year"
                v-model="queryParam.year"
                :open="dataopen"
                format="YYYY"
                :allowClear="false"
                @openChange="openChangeYear"
                @panelChange="panelChangeYear"
              />
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="username"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"

        class="j-table-force-nowrap"
        @change="handleTableChange">
        <template slot="teacherTypeSlot" slot-scope="text, record">
          <a-tag v-if="text=='1-1'" color="#87d068">专职教师</a-tag>
          <a-tag v-else color="#1890FF">兼职教师</a-tag>
        </template>
        <template slot="pointSlot" slot-scope="text, record">
          <a-tag v-if="text<0" color="#87d068">无</a-tag>
          <a-tag v-else color="#1890FF">{{ text }}</a-tag>
        </template>
        <template slot="resultSlot" slot-scope="text, record">
          <a-tag v-if="record.point<0" color="#1890FF">不考核</a-tag>
          <a-tag v-else-if="record.score>=record.point" color="#87d068">达标</a-tag>
          <a-tag v-else color="#f50">不达标</a-tag>
        </template>
      </a-table>
    </div>

<!--    <classtime-score-modal ref="modalForm" @ok="modalFormOk"></classtime-score-modal>-->

  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'

  import moment from 'moment'
  import Vue from 'vue'
  import { CURRENT_DATE } from '@/store/mutation-types'

  export default {
    name: 'classtimePointReport',
    mixins:[JeecgListMixin],
    components: {

    },
    props: ['value'],
    data () {
      return {
        description: '课时统计表管理页面',
        disableMixinCreated:true,
        dataopen: false,
        cardLoading: false,
        queryParam: {
          year: ''
        },
        isorter:{
          column: 'score',
          order: 'desc',
        },
        // 表头
        columns: [
          {
            title:'时间',
            align:"center",
            dataIndex: 'date'
          },

          {
            title:'教师姓名',
            align:"center",
            dataIndex: 'username_dictText'
          },
          {
            title:'职称',
            align:"center",
            dataIndex: 'titleLevel_dictText'
          },
          {
            title:'职务',
            align:"center",
            dataIndex: 'positionLevel_dictText'
          },
          {
            title:'总课时',
            align:"center",
            dataIndex: 'totalClasstime'
          },
          {
            title:'基本指标值',
            align:"center",
            dataIndex: 'point',
            scopedSlots: {customRender: 'pointSlot'}
          },
          {
            title:'得分',
            align:"center",
            dataIndex: 'score'
          },
          {
            title:'考核结果',
            align:"center",
            scopedSlots: {customRender: 'resultSlot'}
          }
        ],
        url: {
          list: "/points/classtimeScore/list",
          delete: "/points/classtimeScore/delete",
          deleteBatch: "/points/classtimeScore/deleteBatch",
          exportXlsUrl: "/points/classtimeScore/exportXls",
          importExcelUrl: "points/classtimeScore/importExcel",

        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
      this.queryParam.year = Vue.ls.get(CURRENT_DATE);
    },
    watch: {
      value: {
        immediate: true,
        handler(obj) {
          this.dataSource = []
          console.log(obj)
          if(obj.isLeaf){
            console.log("查询")
            this.queryParam.orgId = obj.id;
            console.log(this.queryParam)
            this.loadData()
          }

        }
      },
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'year',text:'时间',dictCode:''})
        fieldList.push({type:'string',value:'month',text:'月份',dictCode:''})
        this.superFieldList = fieldList
      },
      // loadData(pageNum, teacherCode){
      //   this.loading = true
      //   if (pageNum === 1) {
      //     this.ipagination.current = 1
      //   }
      //   getAction(this.url.list, {
      //     teacherCode,
      //     ...this.getQueryParams()
      //   }).then((res) => {
      //     console.log(res.result)
      //     if (res.success) {
      //       this.dataSource = res.result.records
      //       this.ipagination.total = res.result.total
      //     }
      //   }).finally(() => {
      //     this.loading = false
      //     this.cardLoading = false
      //   })
      // },
      openChangeYear: function(status) {
        if (status) {
          this.dataopen = true;
        } else {
          this.dataopen = false;
        }
      },
      panelChangeYear: function(value){
        const endOfYear = moment().endOf('year')
        if(value.endOf('year')>endOfYear){
          // alert("所选时间不能超过当前时间");
          this.errorModal('时间选择错误','所选时间不能超过当前时间');
        } else {
          this.queryParam.year = value.format('YYYY');
        }
        this.dataopen = false;
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>